import * as todoLocalStorage from "../utils/todoLocalStorage.js"
import { ref, watchEffect } from "vue"

export function useTodoList() {
    // 使数据具有响应式
    const todoRef = ref(todoLocalStorage.fetchData())
    // window.todoRef = todoRef
    // 监控数据的变化，若变化了就执行该函数
    watchEffect(() => {
        todoLocalStorage.save(todoRef.value)
    })
    return {
        todoRef
    }
}